/**
 * Created by LeungZ on 2016/10/17.
 */
class Ctrl {
    constructor($scope) {
        "ngInject";
        if (!$scope.service.logVols) $scope.service.logVols = [];
    }

    logVolAdd(vols) {
        vols.push({
            name: '',
            path: ''
        })
    }

    logVolRemove(index, vols) {
        vols.splice(index, 1);
    }

    checkLogVolName(index, vols, form) {
        if (vols[index].name) {
            for (var i in vols) {
                if (vols[i].name == vols[index].name && i != index) {
                    return form['logVolName' + index].$setValidity('duplicate', false);
                }
            }
            form['logVolName' + index].$setValidity('duplicate', true);
        }
    }
}
export default Ctrl